package reportdb

import (
	"fmt"
	"github.com/boltdb/bolt"
	"log"
)

type ReportDB struct {
	*bolt.DB
}

var reportDB ReportDB

func New() *ReportDB {
	return &reportDB
}

func initReportDB() (*ReportDB, error) {
	boltdb, err := bolt.Open("report.db", 0600, nil)
	if err != nil {
		return nil, err
	}
	return &ReportDB{boltdb}, nil
}

func init() {
	boltdb, err := bolt.Open("report.db", 0600, nil)
	if err != nil {
		panic(err)
	}
	fmt.Println("begin to init the report db")
	reportDB = ReportDB{boltdb}
}

func (db *ReportDB) initUserBucket() error {
	boltdb, err := bolt.Open("report.db", 0600, nil)
	if err != nil {
		log.Fatal(err)
	}
	defer boltdb.Close()
	return nil
}
